<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function lose(){
				if(!d1.value){
					s1.innerHTML="用户名不能为空"
					return
				}
				if(d1.value.length<6 || d1.value.length>12){
					s1.innerHTML="格式错误"
					return
				}
				var xhr=new XMLHttpRequest()
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4 && xhr.status==200){
						var r=xhr.responseText
						if(r==1){
							s1.innerHTML="该用户名已存在"
						}else{
							s1.innerHTML="√"
						}
					}
				}
				xhr.open("get","/pizza/v1/search/"+d1.value,true)
				xhr.send()
			}
			function show(){
				s1.innerHTML="长度在6~12之间"
			}
			function lose2(){
				if(!d2.value){
					s2.innerHTML="密码不能为空"
				}else if(d2.value<8 || d2.value>16){
					s2.innerHTML="格式不正确"
				}else{
					s2.innerHTML="√"
				}
				
			}
			function show2(){
				s2.innerHTML="密码长度在8~16之间"
			}
		
		</script>
	</head>
	<body>
		用户名<input type="text" id="d1" onblur="lose()" onfocus="show()"><span id="s1"></span><br>
		密码<input type="password" id="d2" onblur="lose2()" onfocus="show2()"><span id="s2"></span><br>
		确认密码<input type="password" id="d3" onblur="lose3()" onfocus="show3()"><span id="s3"></span><br>
		电话<input type="text" id="d4"><span id="s4"></span><br>
		<button onclick="into()">注册</button>
	</body>
</html>
